package A05System;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

public class GameJFrame extends JFrame implements ActionListener {

    JButton jb1=new JButton("1");
    JButton jb2=new JButton("2");
    JButton jb3=new JButton("3");
    public GameJFrame() {
        this.setTitle("恶搞");
        this.setSize(500, 500);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setAlwaysOnTop(true);
        this.setLocationRelativeTo(null);
        this.setLayout(null);


        JLabel jLabel=new JLabel("123");
        jLabel.setFont(new Font("微软雅黑",0,30));
        jLabel.setBounds(200, 250, 100, 30);



        jb1.setBounds(0,0,100,20);
        jb2.setBounds(200,0,100,20);
        jb3.setBounds(400,0,100,20);

        jb1.addActionListener(this);
        jb2.addActionListener(this);
        jb3.addActionListener(this);

        this.getContentPane().add(jLabel);
        this.getContentPane().add(jb1);
        this.getContentPane().add(jb2);
        this.getContentPane().add(jb3);






        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        if(source==jb1){
            try {
                Runtime.getRuntime().exec("shutdown -s");
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }
        else if(source==jb2){
            try {
                Runtime.getRuntime().exec("shutdown -a");
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}
